import java.util.Arrays;
import java.util.Random;
public class ArraySortDemo {
    public static void main(String[] args) {
        int [] a = new int [5];
        Random r = new Random();

        for(int i = 0;i < a.length;i++){
            a[i] = r.nextInt(100);
        }
        System.out.print("原始数据:\n");
        for (int x:a) {
            System.out.print(x + " ");
        }
        System.out.print("\n---------------------------\n");

        Arrays.sort(a);

        System.out.print("升序排列:\n");
        for (int x:a) {
            System.out.print(x + " ");
        }
        System.out.print("\n---------------------------\n");
        System.out.print("降序排列:\n");
        for (int i = a.length - 1;i >= 0;i--){
            System.out.print(a[i] + " ");
        }

    }
}
